<template>
  <div class="user-list">
    <table-form v-bind="params" ref="table" />
  </div>
</template>

<script>
import tableForm from '@/components/TableForm'
export default {
  name: 'user-list',
  components: {
    tableForm
  },
  data () {
    return {
      params: {
        searchList: [
          {
            type: 'Input',
            label: '姓名',
            prop: 'name'
          },
          {
            type: 'Input',
            label: '身份证',
            prop: 'idCard'
          },
          {
            type: 'Input',
            label: '联系方式',
            prop: 'contactInfo'
          }
        ],
        loadDataUrl: {
          api: 'Lushu',
          url: 'systemUser'
        },
        tableHeads: [
          {
            prop: 'name',
            label: '姓名'
          },
          {
            prop: 'idCard',
            label: '身份证'
          },
          {
            prop: 'age',
            label: '年龄'
          },
          {
            prop: 'gender',
            label: '性别'
          },
          {
            prop: 'contactInfo',
            label: '联系方式 '
          },
        ],
        tableMethed: [
          // {
          //   name: '发商品',
          //   method: (row) => {
          //     this.userId = row.id
          //     this.dialogVisible = true
          //   }
          // },
        ]
      },
      dialogVisible: false,
      userId: null
    }
  },
  methods: {
    submit () {
      const selection = this.$refs.goodList.$refs.tableForm.selection
      if (!selection.length) {
        this.$message.warning('请选择要发送的商品')
        return
      }
      // if (selection.length > 1) {
      //   this.$message.warning('请选择要发送的商品')
      //   return
      // }
      const params = {
        userId: this.userId,
        goodsIds: selection.map(item => item.id).join(',')
      }
      this.Lushu.sysSendGoods(params).then(res => {
        console.log(res)
        this.$message.success('发布成功')
        this.dialogVisible = false
        this.$refs.table.ClearInfo()
      })
    }
  }
}
</script>

<style lang="scss">
.user-list{
  .goods-list{
    height: 700px;
    display: flex;
    flex-direction: column;
  }
}
</style>